package com.example.xinhuazidian.adapter

import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.xinhuazidian.R
import com.example.xinhuazidian.bean.Baijiaxing

class BJXAdapter(private val list: MutableList<Baijiaxing.OriginBean>) :
    RecyclerView.Adapter<BJXAdapter.MyViewHolder>() {

    inner class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        val tvSurname: TextView = view.findViewById(R.id.tvSurname)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
        val view =
            LayoutInflater.from(parent.context).inflate(R.layout.item_baijiaxing, parent, false)
        return MyViewHolder(view)
    }

    @SuppressLint("SetTextI18n")
    override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
        val appInfo = this.list[position]
        with(holder) {
            tvSurname.text = "${appInfo.surname}——${appInfo.place}"
        }
    }

    override fun getItemCount() = list.size
}

